Skip to content

Fix some compilation warnings.#33

Open
martin-barta-sie wants to merge 1 commit intosiemens:masterfrom
martin-barta-sie:fix/warning
Open

Fix some compilation warnings.#33
martin-barta-sie wants to merge 1 commit intosiemens:masterfrom
martin-barta-sie:fix/warning

Conversation

@martin-barta-sie
Copy link
Contributor

No description provided.

Copy link
Member

@DDvO DDvO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for these fixes;
just a couple of improvements suggested.

len = SECTION_NAME_MAX;
}
strncpy(opt_item, beg, len);
if(len > 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This guard is not needed since it is equivalent to len != 0, and if len == 0, strncpy() will do nothing anyway.

Comment on lines +110 to +111
assert(beg <= end);
size_t len = (size_t)(end - beg);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, from the five lines before it should already be clear that beg <= end.
So I do not see the need for the assertion and thus also not for the include <assert.h>.
Yet maybe append to the next (assignment) line a comment such as: /* note that beg <= end */.

Comment on lines +87 to +88
assert(pos_p >= src_p);
line_len = (size_t)(pos_p - src_p);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here, I suggest replacing the new assertion by, e.g., /* note that pos_p >= src_p */ at the end of the following line
and removing the #include <assert.h>.

@@ -51,9 +52,9 @@ static int file_modified;
* Keeps any end-of-line comment.
* Returns the length of the resulting line, or 0 in case of error.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please correct the comment: or -1 in case of error.

Comment on lines +124 to +125
assert(end is_eq 0 or end >= uri);
size_t len = end not_eq 0 ? (size_t)(end - uri) : strlen(uri);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here, I suggest not using assert() but optionally just adding a comment.

for(i = 0; i < num_out; i++)
{
char c = *((*in_p)++);
int c = *((*in_p)++);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?
Note that *in_p is of type const char*

{
(*decoded_len)--;
}
assert(*decoded_len >= 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here, I suggest replacing the assertion by a comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants